This dataset contains 2022-2023 football player of Premier League stats per 90 minutes.¶
In [4]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
fb_py = pd.read_excel('FootballPlayer.xlsx')
fb_py.head()
Out[4]:
| Rk | Player | Nation | Pos | Squad | Comp | Age | Born | MP | Starts | ... | Off | Crs | TklW | PKwon | PKcon | OG | Recov | AerWon | AerLost | AerWon% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | Brenden Aaronson | USA | MFFW | Leeds United | Premier League | 22 | 2000 | 20 | 19 | ... | 0.17 | 2.54 | 0.51 | 0.0 | 0.0 | 0.0 | 4.86 | 0.34 | 1.19 | 22.2 |
| 1 | 2 | Che Adams | SCO | FW | Southampton | Premier League | 26 | 1996 | 21 | 18 | ... | 0.40 | 0.51 | 0.69 | 0.0 | 0.0 | 0.0 | 2.29 | 2.97 | 5.03 | 37.1 |
| 2 | 3 | Tyler Adams | USA | MF | Leeds United | Premier League | 23 | 1999 | 19 | 19 | ... | 0.05 | 0.11 | 2.00 | 0.0 | 0.0 | 0.0 | 8.68 | 0.89 | 0.63 | 58.6 |
| 3 | 4 | Tosin Adarabioyo | ENG | DF | Fulham | Premier League | 25 | 1997 | 14 | 12 | ... | 0.00 | 0.08 | 0.41 | 0.0 | 0.0 | 0.0 | 4.67 | 2.13 | 0.41 | 83.9 |
| 4 | 5 | Nayef Aguerd | MAR | DF | West Ham | Premier League | 26 | 1996 | 6 | 5 | ... | 0.18 | 0.00 | 1.58 | 0.0 | 0.0 | 0.0 | 5.26 | 1.75 | 1.05 | 62.5 |
5 rows × 124 columns
In [5]:
fb_py[fb_py.isnull().any(axis=1)]
Out[5]:
| Rk | Player | Nation | Pos | Squad | Comp | Age | Born | MP | Starts | ... | Off | Crs | TklW | PKwon | PKcon | OG | Recov | AerWon | AerLost | AerWon% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 372 | 373 | David Ozoh | NaN | FW | Crystal Palace | Premier League | 17 | 2005 | 1 | 0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1 rows × 124 columns
In [6]:
# มีตำแหน่งใดบ้าง
fb_py['Pos'].unique()
Out[6]:
array(['MFFW', 'FW', 'MF', 'DF', 'FWMF', 'GK', 'DFMF', 'FWDF', 'DFFW',
'MFDF'], dtype=object)
In [7]:
#df = df.drop(['CL1', 'CL2', 'CL3', 'CL4'], axis = 1) drop column
สร้าง DataFrame ใหม่ขึ้น¶
In [8]:
fb_py_new = pd.DataFrame()
In [9]:
fb_py_new['Player'] = fb_py ['Player']
fb_py_new['Nation'] = fb_py ['Nation']
fb_py_new['Position'] = fb_py ['Pos']
fb_py_new['Team'] = fb_py ['Squad']
fb_py_new['Age'] = fb_py ['Age']
fb_py_new['Match'] = fb_py ['MP']
fb_py_new['Goals'] = fb_py ['Goals']
fb_py_new['Tackled'] = fb_py ['Tkl']
fb_py_new['CreatShot'] = fb_py ['SCA']
fb_py_new['Assist'] = ((fb_py['Assists'] * fb_py['Min']) / 90).round(0).astype(int)
fb_py_new['Pass'] = ((fb_py ['PasTotAtt'] * fb_py ['Min']) / 90).round(0).astype(int) #การผ่านบอล
fb_py_new['PassCompleted'] = ((fb_py ['PasTotCmp'] * fb_py ['Min']) / 90).round(0).astype(int) #ผ่านบอลสำเร็จ
fb_py_new['PassComp%'] = fb_py['PasTotCmp%'] #ผ่านบอลสำเร็จ
fb_py_new['TackleWon'] = ((fb_py ['TklWon'] * fb_py ['Min']) / 90).round(0).astype(int)
fb_py_new['YCards'] = ((fb_py ['CrdY'] * fb_py ['Min']) / 90).round(0).astype(int)
fb_py_new['RCards'] = ((fb_py ['CrdR'] * fb_py ['Min']) / 90).round(0).astype(int)
fb_py_new['Fls'] = ((fb_py['Fls'] * fb_py['Min']) / 90).round(0).astype(int)
fb_py_new['AirWon'] = ((fb_py['AerWon'] * fb_py['Min']) / 90).round(0).astype(int) #ชนะการดวลลูกกลางอากาศ
fb_py_new['AirWon%'] = ((fb_py['AerWon'] / (fb_py['AerWon'] + fb_py['AerLost'])) * 100).round(2) #ชนะการดวลลูกกลางอากาศ %
fb_py_new['Cross'] = ((fb_py['PasCrs'] * fb_py['Min']) / 90).round(0).astype(int)#ครอสบอลต่อเกม
fb_py_new['CrossCompleted'] = ((fb_py['CrsPA'] * fb_py['Min']) / 90).round(0).astype(int) #ครอสบอลสำเร็จต่อเกม
fb_py_new['CrossComp%'] = ((fb_py_new['CrossCompleted'] / fb_py_new['Cross']) * 100).round(2) #ครอสบอลสำเร็จต่อเกม %
fb_py_new['Dribble'] = ((fb_py['TklDri'] * fb_py['Min']) / 90).round(0).astype(int)
fb_py_new['DribbleCompleted'] = ((fb_py['ScaDrib'] * fb_py['Min']) / 90).round(0).astype(int) #เลี้ยงบอลผ่านต่อเกม
In [10]:
fb_py_new
Out[10]:
| Player | Nation | Position | Team | Age | Match | Goals | Tackled | CreatShot | Assist | ... | YCards | RCards | Fls | AirWon | AirWon% | Cross | CrossCompleted | CrossComp% | Dribble | DribbleCompleted | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Brenden Aaronson | USA | MFFW | Leeds United | 22 | 20 | 1 | 1.64 | 3.62 | 2 | ... | 2 | 0 | 11 | 6 | 22.22 | 45 | 2 | 4.44 | 9 | 4 |
| 1 | Che Adams | SCO | FW | Southampton | 26 | 21 | 4 | 0.86 | 2.63 | 2 | ... | 0 | 0 | 31 | 52 | 37.12 | 9 | 2 | 22.22 | 7 | 1 |
| 2 | Tyler Adams | USA | MF | Leeds United | 23 | 19 | 0 | 4.11 | 1.84 | 0 | ... | 5 | 1 | 33 | 17 | 58.55 | 2 | 0 | 0.00 | 42 | 0 |
| 3 | Tosin Adarabioyo | ENG | DF | Fulham | 25 | 14 | 1 | 1.07 | 0.41 | 0 | ... | 2 | 0 | 8 | 26 | 83.86 | 1 | 0 | 0.00 | 6 | 0 |
| 4 | Nayef Aguerd | MAR | DF | West Ham | 26 | 6 | 0 | 2.28 | 0.18 | 0 | ... | 3 | 0 | 4 | 10 | 62.50 | 0 | 0 | NaN | 7 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 535 | Jordan Zemura | ZIM | DF | Bournemouth | 23 | 16 | 0 | 2.44 | 2.22 | 1 | ... | 1 | 0 | 14 | 6 | 37.29 | 14 | 4 | 28.57 | 20 | 6 |
| 536 | Oleksandr Zinchenko | UKR | DF | Arsenal | 26 | 14 | 0 | 1.92 | 2.08 | 1 | ... | 2 | 0 | 2 | 21 | 75.11 | 22 | 3 | 13.64 | 11 | 0 |
| 537 | Hakim Ziyech | MAR | FWMF | Chelsea | 29 | 12 | 0 | 3.16 | 3.68 | 1 | ... | 0 | 0 | 8 | 0 | 0.00 | 54 | 6 | 11.11 | 4 | 1 |
| 538 | Kurt Zouma | FRA | DF | West Ham | 28 | 15 | 1 | 0.28 | 0.28 | 0 | ... | 0 | 0 | 7 | 37 | 88.18 | 0 | 0 | NaN | 3 | 0 |
| 539 | Martin Ødegaard | NOR | MF | Arsenal | 24 | 20 | 15 | 1.02 | 5.08 | 5 | ... | 3 | 0 | 19 | 9 | 40.68 | 47 | 2 | 4.26 | 4 | 2 |
540 rows × 24 columns
In [11]:
fb_py_new.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 540 entries, 0 to 539 Data columns (total 24 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Player 540 non-null object 1 Nation 539 non-null object 2 Position 540 non-null object 3 Team 540 non-null object 4 Age 540 non-null int64 5 Match 540 non-null int64 6 Goals 540 non-null int64 7 Tackled 540 non-null float64 8 CreatShot 540 non-null float64 9 Assist 540 non-null int64 10 Pass 540 non-null int64 11 PassCompleted 540 non-null int64 12 PassComp% 540 non-null float64 13 TackleWon 540 non-null int64 14 YCards 540 non-null int64 15 RCards 540 non-null int64 16 Fls 540 non-null int64 17 AirWon 540 non-null int64 18 AirWon% 489 non-null float64 19 Cross 540 non-null int64 20 CrossCompleted 540 non-null int64 21 CrossComp% 387 non-null float64 22 Dribble 540 non-null int64 23 DribbleCompleted 540 non-null int64 dtypes: float64(5), int64(15), object(4) memory usage: 101.4+ KB
In [12]:
plt.figure(figsize=(12, 8))
corr_matrix = fb_py_new[['CreatShot',
'Assist',
'Pass',
'PassCompleted',
'PassComp%',
'TackleWon',
'YCards',
'RCards',
'Fls',
'AirWon',
'AirWon%',
'Cross',
'CrossCompleted',
'CrossComp%',
'Dribble',
'DribbleCompleted']].corr()
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', vmin=-1, vmax=1)
plt.title('Correlation Matrix')
plt.show()
สถิติการยิงประตู¶
In [13]:
total_goals = fb_py_new['Goals'].sum()
print("จำนวนประตูทั้งหมดในลีค :", total_goals , 'ประตู')
จำนวนประตูทั้งหมดในลีค : 728 ประตู
In [14]:
# 10 อันดับผู้เล่นที่ยิงประตูมากที่สุด
(fb_py_new.sort_values('Goals', ascending = False).head(10).iloc[:, [0,2,3,4,5,6]])
Out[14]:
| Player | Position | Team | Age | Match | Goals | |
|---|---|---|---|---|---|---|
| 208 | Erling Haaland | FW | Manchester City | 22 | 37 | 36 |
| 252 | Harry Kane | FW | Tottenham | 29 | 23 | 30 |
| 489 | Ivan Toney | FW | Brentford | 26 | 20 | 20 |
| 427 | Mohamed Salah | FW | Liverpool | 30 | 20 | 19 |
| 523 | Callum Wilson | FW | Newcastle Utd | 30 | 16 | 18 |
| 398 | Marcus Rashford | FW | Manchester Utd | 25 | 22 | 17 |
| 514 | Ollie Watkins | FW | Aston Villa | 27 | 20 | 15 |
| 539 | Martin Ødegaard | MF | Arsenal | 24 | 20 | 15 |
| 310 | Martinelli | FW | Arsenal | 21 | 21 | 15 |
| 426 | Bukayo Saka | FW | Arsenal | 21 | 21 | 14 |
In [15]:
goal_py = fb_py_new.groupby('Player')['Goals'].sum().reset_index()
goal_py_sorted = goal_py.sort_values(by='Goals', ascending=False)
top_10 = goal_py_sorted.head(10)
# Plotting
plt.figure(figsize=(13,3))
plt.bar(top_10['Player'], top_10['Goals'], color='red')
plt.xlabel('Name')
plt.ylabel('Total Goals Scored')
plt.title('Top 10 Players list of goal scorers Premier League 2022 - 2023')
plt.xticks(rotation=90)
plt.show()
In [16]:
haaland_goals = fb_py_new[fb_py_new['Player'] == 'Erling Haaland']['Goals'].sum()
print("จำนวนการยิงประตูทั้งหมดของ Erling Haaland:", haaland_goals , ' ประตู')
จำนวนการยิงประตูทั้งหมดของ Erling Haaland: 36 ประตู
In [17]:
fig = px.scatter(fb_py_new, x='Age', y='Goals', trendline='ols')
fig.update_layout(xaxis_title='อายุ',yaxis_title='จำนวนประตู',title = 'กราฟอายุต่อจำนวนประตู')
In [18]:
fig = px.scatter(fb_py_new, x='Goals', y='Match')
fig.update_layout(xaxis_title='Goals',yaxis_title='Match',title = 'กราฟจำนวนเกมต่อจำนวนประตู')
สถิติการเลี้ยงบอล¶
In [19]:
# 5 อันดับนักเตะเลี้ยงบอลสำเร็จมากที่สุด
(fb_py_new.sort_values('DribbleCompleted', ascending = False).head(5).iloc[:, [0,2,3,4,5,23]])
Out[19]:
| Player | Position | Team | Age | Match | DribbleCompleted | |
|---|---|---|---|---|---|---|
| 336 | Aleksandar Mitrovic | FW | Fulham | 28 | 19 | 9 |
| 238 | Gabriel Jesus | FW | Arsenal | 25 | 14 | 9 |
| 268 | Dejan Kulusevski | MFFW | Tottenham | 22 | 15 | 8 |
| 398 | Marcus Rashford | FW | Manchester Utd | 25 | 22 | 8 |
| 306 | Solly March | FWDF | Brighton | 28 | 21 | 8 |
สถิติการผ่านบอล¶
In [20]:
# 10 อันดับนักเตะผ่านบอลสำเร็จมากที่สุด
(fb_py_new.sort_values('PassCompleted', ascending = False).head(10).iloc[:, [0,2,3,4,5,11,10]])
Out[20]:
| Player | Position | Team | Age | Match | PassCompleted | Pass | |
|---|---|---|---|---|---|---|---|
| 413 | Rodri | MF | Manchester City | 26 | 20 | 1702 | 1866 |
| 141 | Lewis Dunk | DF | Brighton | 31 | 21 | 1543 | 1717 |
| 451 | Thiago Silva | DF | Chelsea | 38 | 20 | 1451 | 1609 |
| 226 | Pierre Højbjerg | MF | Tottenham | 27 | 22 | 1277 | 1445 |
| 428 | William Saliba | DF | Arsenal | 21 | 21 | 1238 | 1350 |
| 129 | Eric Dier | DF | Tottenham | 29 | 22 | 1221 | 1417 |
| 499 | Virgil van Dijk | DF | Liverpool | 31 | 17 | 1180 | 1325 |
| 404 | Declan Rice | MF | West Ham | 24 | 22 | 1162 | 1324 |
| 135 | Gabriel Dos Santos | DF | Arsenal | 25 | 21 | 1161 | 1302 |
| 493 | Kieran Trippier | DF | Newcastle Utd | 32 | 22 | 1133 | 1587 |
In [21]:
# 10 อันดับนักเตะที่มีเปอร์เซ็นผ่านบอลสำเร็จมากที่สุด ในตำแหน่งกองกลางที่เล่นมากกว่า 15 เกม
(fb_py_new[(fb_py_new.Match>=15) & (fb_py_new.Position.str.contains('MF'))].sort_values('PassComp%', ascending = False).head(10).iloc[:, [0,2,3,5,12]])
Out[21]:
| Player | Position | Team | Match | PassComp% | |
|---|---|---|---|---|---|
| 413 | Rodri | MF | Manchester City | 20 | 91.3 |
| 57 | Yves Bissouma | MF | Tottenham | 20 | 90.0 |
| 226 | Pierre Højbjerg | MF | Tottenham | 22 | 88.4 |
| 296 | Alexis Mac Allister | MF | Brighton | 18 | 88.4 |
| 70 | Moisés Caicedo | MF | Brighton | 20 | 88.2 |
| 157 | Fabinho | MF | Liverpool | 18 | 88.1 |
| 404 | Declan Rice | MF | West Ham | 22 | 87.8 |
| 206 | Ýlkay Gündoðan | MF | Manchester City | 18 | 87.3 |
| 349 | Wilfred Ndidi | MFDF | Leicester City | 15 | 87.0 |
| 377 | Thomas Partey | MF | Arsenal | 18 | 86.2 |
In [22]:
# ทีมที่ผ่านบอลสำเร็จมากที่สุดในลีค
team_pass = fb_py_new.groupby(['Team']).agg(Pass_Attempted = ('Pass', 'sum'),
Pass_Completion = ('PassCompleted', 'sum'))
team_pass = pd.DataFrame(team_pass).reset_index()
team_pass['PassComp%'] = ((team_pass['Pass_Completion'] / team_pass['Pass_Attempted']) * 100).round(2)
team_pass = team_pass.sort_values('PassComp%', ascending = False).head(1).iloc[:, [0,-1]]
team_pass
Out[22]:
| Team | PassComp% | |
|---|---|---|
| 12 | Manchester City | 87.35 |
In [23]:
# 5 อันดับนักเตะที่มีเปอร์เซ็นครอสบอลสำเร็จมากที่สุด ในตำแหน่งกองกลางที่เล่นมากกว่า 20 เกม
(fb_py_new[(fb_py_new.Match>=20) & (fb_py_new.Position.str.contains('MF'))].sort_values('CrossComp%', ascending = False).head(5).iloc[:, [0,2,3,5,21]])
Out[23]:
| Player | Position | Team | Match | CrossComp% | |
|---|---|---|---|---|---|
| 57 | Yves Bissouma | MF | Tottenham | 20 | 50.00 |
| 226 | Pierre Højbjerg | MF | Tottenham | 22 | 45.45 |
| 70 | Moisés Caicedo | MF | Brighton | 20 | 44.44 |
| 413 | Rodri | MF | Manchester City | 20 | 33.33 |
| 461 | Tomáš Sou?ek | MF | West Ham | 22 | 33.33 |
In [24]:
# 5 อันดับนักเตะครอสบอลสำเร็จมากที่สุด
(fb_py_new.sort_values('CrossCompleted', ascending = False).head(5).iloc[:, [0,2,3,4,5,20,19]])
Out[24]:
| Player | Position | Team | Age | Match | CrossCompleted | Cross | |
|---|---|---|---|---|---|---|---|
| 493 | Kieran Trippier | DF | Newcastle Utd | 32 | 22 | 20 | 226 |
| 384 | Ivan Periši? | DFMF | Tottenham | 34 | 23 | 18 | 126 |
| 13 | Trent Alexander-Arnold | DF | Liverpool | 24 | 20 | 17 | 137 |
| 119 | Kevin De Bruyne | MF | Manchester City | 31 | 20 | 14 | 157 |
| 106 | Aaron Cresswell | DF | West Ham | 33 | 18 | 13 | 101 |
In [25]:
# 5 อันดับนักเตะครอสบอลสำเร็จมากที่สุด ที่เกิน 10 ครั้ง
(fb_py_new[fb_py_new['CrossCompleted']>= 10].sort_values('CrossCompleted', ascending = False).head(5).iloc[:, [0,2,3,4,5,20,21]])
Out[25]:
| Player | Position | Team | Age | Match | CrossCompleted | CrossComp% | |
|---|---|---|---|---|---|---|---|
| 493 | Kieran Trippier | DF | Newcastle Utd | 32 | 22 | 20 | 8.85 |
| 384 | Ivan Periši? | DFMF | Tottenham | 34 | 23 | 18 | 14.29 |
| 13 | Trent Alexander-Arnold | DF | Liverpool | 24 | 20 | 17 | 12.41 |
| 119 | Kevin De Bruyne | MF | Manchester City | 31 | 20 | 14 | 8.92 |
| 106 | Aaron Cresswell | DF | West Ham | 33 | 18 | 13 | 12.87 |
ช่วยทำประตู¶
In [26]:
# 5 ผู้เล่นที่สร้างสรรค์โอกาสต่อเกมมากสุดในลีค
fb_py_new[(fb_py_new.Match>=15)].sort_values('CreatShot', ascending = False).head(5).iloc[:, [0,2,8]]
Out[26]:
| Player | Position | CreatShot | |
|---|---|---|---|
| 119 | Kevin De Bruyne | MF | 6.52 |
| 300 | Riyad Mahrez | FWMF | 5.70 |
| 539 | Martin Ødegaard | MF | 5.08 |
| 71 | Tom Cairney | MF | 5.00 |
| 162 | Bruno Fernandes | MFFW | 4.95 |
In [27]:
# 5 ผู้เล่นที่ช่วยทำประตูมากสุดในลีค
fb_py_new.sort_values('Assist', ascending = False).head(5).iloc[:, [0,2,9]]
Out[27]:
| Player | Position | Assist | |
|---|---|---|---|
| 119 | Kevin De Bruyne | MF | 11 |
| 426 | Bukayo Saka | FW | 8 |
| 152 | Christian Eriksen | MF | 7 |
| 381 | Andreas Pereira | MF | 6 |
| 530 | Granit Xhaka | MF | 5 |
เข้าปะทะ¶
In [28]:
# 5 ผู้เล่นที่เข้าปะทะชนะ
fb_py_new.sort_values('TackleWon', ascending = False).head(5).iloc[:, [0,2,5,13]]
Out[28]:
| Player | Position | Match | TackleWon | |
|---|---|---|---|---|
| 373 | João Palhinha | MF | 22 | 56 |
| 473 | Pascal Struijk | DF | 20 | 44 |
| 2 | Tyler Adams | MF | 19 | 38 |
| 137 | Cheick Doucouré | MF | 20 | 35 |
| 240 | Joelinton | MFFW | 20 | 35 |
In [29]:
# ทีมที่เข้าปะทะชนะ มากที่สุด
t_tackle_won = fb_py_new.groupby(['Team']).agg(T_TackleWon = ('TackleWon', 'sum'))
t_tackle_won = pd.DataFrame(t_tackle_won).reset_index()
t_tackle_won.sort_values('T_TackleWon', ascending = False).head(1)
Out[29]:
| Team | T_TackleWon | |
|---|---|---|
| 9 | Leeds United | 278 |
การทำฟาล์ว¶
In [30]:
#5 ผู้เล่นที่ที่ทำฟาล์วมากที่สุด
fb_py_new.sort_values('Fls', ascending = False).head(5).iloc[:, [0,2,3,4,5,16]]
Out[30]:
| Player | Position | Team | Age | Match | Fls | |
|---|---|---|---|---|---|---|
| 212 | Kai Havertz | FWMF | Chelsea | 23 | 21 | 41 |
| 70 | Moisés Caicedo | MF | Brighton | 21 | 20 | 39 |
| 240 | Joelinton | MFFW | Newcastle Utd | 26 | 20 | 37 |
| 531 | Ryan Yates | MF | Nott'ham Forest | 25 | 18 | 37 |
| 442 | Jeffrey Schlupp | MF | Crystal Palace | 30 | 22 | 36 |
In [31]:
#10 ผู้เล่นที่ได้รับใบเหลืองมากที่สุด
fb_py_new.sort_values('YCards', ascending = False).head(10).iloc[:, [0,2,3,4,5,14]]
Out[31]:
| Player | Position | Team | Age | Match | YCards | |
|---|---|---|---|---|---|---|
| 240 | Joelinton | MFFW | Newcastle Utd | 26 | 20 | 9 |
| 52 | Rodrigo Bentancur | MF | Tottenham | 25 | 18 | 8 |
| 489 | Ivan Toney | FW | Brentford | 26 | 20 | 8 |
| 373 | João Palhinha | MF | Fulham | 27 | 22 | 8 |
| 403 | Bobby Reid | FWDF | Fulham | 30 | 22 | 7 |
| 416 | Cristian Romero | DF | Tottenham | 24 | 14 | 7 |
| 204 | Marc Guéhi | DF | Crystal Palace | 22 | 21 | 7 |
| 137 | Cheick Doucouré | MF | Crystal Palace | 23 | 20 | 7 |
| 353 | Rúben Neves | MF | Wolves | 25 | 21 | 7 |
| 455 | Adam Smith | DF | Bournemouth | 31 | 21 | 7 |
In [32]:
#ผู้เล่นที่ได้รับใบแดงในลีคทั้งหมด
fb_py_new.sort_values('RCards', ascending = False).head().iloc[:, [0,2,3,4,5,15]]
Out[32]:
| Player | Position | Team | Age | Match | RCards | |
|---|---|---|---|---|---|---|
| 2 | Tyler Adams | MF | Leeds United | 23 | 19 | 1 |
| 75 | João Cancelo | DF | Manchester City | 28 | 17 | 1 |
| 102 | Diego Costa | FW | Wolves | 34 | 10 | 1 |
| 85 | Nathaniel Chalobah | MF | Fulham | 28 | 4 | 1 |
| 151 | Emerson | DF | Tottenham | 24 | 18 | 1 |
การดวลลูกกลางอากาศ¶
In [33]:
#10 ผู้เล่นที่มีเปอร์เซ็นชนะการดวลลูกกลางอากาศ ที่เล่นมากกว่า 15 เกม
(fb_py_new[(fb_py_new.Match >= 15) & (fb_py_new.Position.str.contains('DF'))].sort_values('AirWon%', ascending = False).head(10).iloc[:, [0,2,5,3,4,18]])
Out[33]:
| Player | Position | Match | Team | Age | AirWon% | |
|---|---|---|---|---|---|---|
| 538 | Kurt Zouma | DF | 15 | West Ham | 28 | 88.18 |
| 499 | Virgil van Dijk | DF | 17 | Liverpool | 31 | 78.53 |
| 529 | Joe Worrall | DF | 17 | Nott'ham Forest | 26 | 72.57 |
| 75 | João Cancelo | DF | 17 | Manchester City | 28 | 71.16 |
| 479 | James Tarkowski | DF | 21 | Everton | 30 | 69.87 |
| 500 | Raphaël Varane | DF | 17 | Manchester Utd | 29 | 69.60 |
| 515 | Adam Webster | DF | 16 | Brighton | 28 | 69.11 |
| 19 | Joachim Andersen | DF | 17 | Crystal Palace | 26 | 68.93 |
| 110 | Diogo Dalot | DF | 15 | Manchester Utd | 23 | 68.55 |
| 451 | Thiago Silva | DF | 20 | Chelsea | 38 | 68.44 |
In [34]:
#คนที่ 1 ตำแหน่งหน้าเป้า เลือกจากการยิงประตูสูง อายุไม่เกิน 32 และมีการชนะลูกกลางอากาศที่ดี ยิงมากกว่า 20 ประตู
FW_1= (fb_py_new[(fb_py_new.Match>=20) &
(fb_py_new['Age'] < 32) &
(fb_py_new['Position'] == 'FW') &
(fb_py_new['Goals'] >= 15) &
(fb_py_new.Position.str.contains('FW'))].sort_values(['Goals','AirWon%'], ascending = False).head(5).iloc[:, [0,2,3,4,5,6,18]])
FW_1
Out[34]:
| Player | Position | Team | Age | Match | Goals | AirWon% | |
|---|---|---|---|---|---|---|---|
| 208 | Erling Haaland | FW | Manchester City | 22 | 37 | 36 | 52.09 |
| 252 | Harry Kane | FW | Tottenham | 29 | 23 | 30 | 46.42 |
| 489 | Ivan Toney | FW | Brentford | 26 | 20 | 20 | 48.26 |
| 427 | Mohamed Salah | FW | Liverpool | 30 | 20 | 19 | 19.74 |
| 398 | Marcus Rashford | FW | Manchester Utd | 25 | 22 | 17 | 36.02 |
In [35]:
FW_1_is = FW_1['Player'].head(1)
print('ตำแหน่งกองหน้าตัวเป้าคนแรก คือ ', FW_1_is )
ตำแหน่งกองหน้าตัวเป้าคนแรก คือ 208 Erling Haaland Name: Player, dtype: object
In [36]:
#คนที่ 2 3 ตำแหน่งหน้าซ้าย และ หน้าขวา เลือกจากการยิงประตูสูงมากกว่า 15 ประตู อายุไม่เกิน 32 และมีการชนะลูกกลางอากาศที่ดี ยิงมากกว่า 20 ประตู
FW_2_3= (fb_py_new[(fb_py_new.Match>=20) &
(fb_py_new['Age'] < 32) &
(fb_py_new['Position'] == 'FW') &
(fb_py_new['DribbleCompleted'] >= 5) &
(fb_py_new.Position.str.contains('FW'))].sort_values(['Goals'], ascending = False).head(10).iloc[:, [0,2,3,4,5,6,23]])
FW_2_3
Out[36]:
| Player | Position | Team | Age | Match | Goals | DribbleCompleted | |
|---|---|---|---|---|---|---|---|
| 252 | Harry Kane | FW | Tottenham | 29 | 23 | 30 | 7 |
| 427 | Mohamed Salah | FW | Liverpool | 30 | 20 | 19 | 5 |
| 398 | Marcus Rashford | FW | Manchester Utd | 25 | 22 | 17 | 8 |
| 16 | Miguel Almirón | FW | Newcastle Utd | 29 | 22 | 11 | 7 |
In [37]:
FW_2_3_is = FW_2_3['Player'].head(2)
print('ตำแหน่งกองหน้าขวา และ หน้าซ้าย คือ ' )
FW_2_3_is
ตำแหน่งกองหน้าขวา และ หน้าซ้าย คือ
Out[37]:
252 Harry Kane 427 Mohamed Salah Name: Player, dtype: object
In [38]:
#คนที่ 4 5 ตำแหน่งกองกลาง ตัวรุก เลือกจากจำนวน Assist , การผ่านบอลสำเร็จและเปอร์เซ็น , การสร้างโอกาสต่อเกม
MF_4_5= (fb_py_new[(fb_py_new.Match>=15) &
(fb_py_new['Position'] == 'MF') &
(fb_py_new['Age'] < 32) &
(fb_py_new['Assist'] >= 5 ) &
(fb_py_new['PassCompleted'] >= 500) &
(fb_py_new['PassComp%'] >= 40) &
(fb_py_new['CreatShot'] >= 3) &
(fb_py_new.Position.str.contains('MF'))].sort_values(['Assist','CreatShot'], ascending = False).head(10).iloc[:, [0,2,3,4,5,9,11,12,8]])
MF_4_5
Out[38]:
| Player | Position | Team | Age | Match | Assist | PassCompleted | PassComp% | CreatShot | |
|---|---|---|---|---|---|---|---|---|---|
| 119 | Kevin De Bruyne | MF | Manchester City | 31 | 20 | 11 | 760 | 71.9 | 6.52 |
| 539 | Martin Ødegaard | MF | Arsenal | 24 | 20 | 5 | 717 | 79.1 | 5.08 |
| 530 | Granit Xhaka | MF | Arsenal | 30 | 21 | 5 | 851 | 84.7 | 3.69 |
In [39]:
MF_4_5_is = MF_4_5['Player'].head(2)
print('ตำแหน่งกองกลางตัวรุก คือ ' )
MF_4_5_is
ตำแหน่งกองกลางตัวรุก คือ
Out[39]:
119 Kevin De Bruyne 539 Martin Ødegaard Name: Player, dtype: object
In [40]:
#คนที่ 6 ตำแหน่งกองกลาง ตัวรับ เลือกจากจำนวน Assist , การผ่านบอลสำเร็จและเปอร์เซ็น , การสร้างโอกาสต่อเกม
MF_6= (fb_py_new[(fb_py_new.Match>=20) &
(fb_py_new['Position'] == 'MF') &
(fb_py_new['Age'] < 32) &
(fb_py_new['PassCompleted'] >= 1000) &
(fb_py_new['TackleWon'] >= 20 ) &
(fb_py_new['PassComp%'] >= 80) &
(fb_py_new.Position.str.contains('MF'))].sort_values(['TackleWon','PassComp%'], ascending = False).head(10).iloc[:, [0,2,3,4,5,11,10,12,13]])
MF_6
Out[40]:
| Player | Position | Team | Age | Match | PassCompleted | Pass | PassComp% | TackleWon | |
|---|---|---|---|---|---|---|---|---|---|
| 413 | Rodri | MF | Manchester City | 26 | 20 | 1702 | 1866 | 91.3 | 28 |
| 70 | Moisés Caicedo | MF | Brighton | 21 | 20 | 1039 | 1180 | 88.2 | 28 |
| 353 | Rúben Neves | MF | Wolves | 25 | 21 | 1079 | 1306 | 82.6 | 25 |
| 404 | Declan Rice | MF | West Ham | 24 | 22 | 1162 | 1324 | 87.8 | 21 |
In [41]:
MF_6_is = MF_6['Player'].head(1)
print('ตำแหน่งกองกลางตัวรับ คือ ' )
MF_6_is
ตำแหน่งกองกลางตัวรับ คือ
Out[41]:
413 Rodri Name: Player, dtype: object
In [42]:
#คนที่ 7 8 ตำแหน่งกองหลังเซ็นเตอร์ เลือกจากเปอร์เซ็นการผ่านบอลสำเร็จ , การชนะการดวลกลางอากาศ
DF_7_8= (fb_py_new[(fb_py_new.Match>=15) &
(fb_py_new['Position'] == 'DF') &
(fb_py_new['Age'] < 32) &
(fb_py_new['PassComp%'] >= 70) &
(fb_py_new['AirWon'] >= 20) &
(fb_py_new['AirWon%'] >= 70) &
(fb_py_new.Position.str.contains('DF'))].sort_values(['AirWon%','PassComp%'], ascending = False).head(15).iloc[:, [0,2,3,4,5,12,17,18,16,13,15]])
DF_7_8
Out[42]:
| Player | Position | Team | Age | Match | PassComp% | AirWon | AirWon% | Fls | TackleWon | RCards | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 538 | Kurt Zouma | DF | West Ham | 28 | 15 | 85.6 | 37 | 88.18 | 7 | 2 | 0 |
| 499 | Virgil van Dijk | DF | Liverpool | 31 | 17 | 89.1 | 44 | 78.53 | 6 | 3 | 0 |
| 529 | Joe Worrall | DF | Nott'ham Forest | 26 | 17 | 80.1 | 29 | 72.57 | 19 | 13 | 0 |
| 75 | João Cancelo | DF | Manchester City | 28 | 17 | 84.9 | 27 | 71.16 | 13 | 21 | 1 |
In [43]:
DF_7_8_is = DF_7_8['Player'].head(2)
print('ตำแหน่งกองหลังเซ็นเตอร์ คือ ' )
DF_7_8_is
ตำแหน่งกองหลังเซ็นเตอร์ คือ
Out[43]:
538 Kurt Zouma 499 Virgil van Dijk Name: Player, dtype: object
In [44]:
#คนที่ 9 10 ตำแหน่งกองหลังปีกซ้าย ขวา เลือกจากเปอร์เซ็นการผ่านบอลสำเร็จ ,การครอสบอลจากด้านข้างสำเร็จเกิน 10 ครั้ง, เปอร์เซ็นการผ่านบอล
DF_9_10= (fb_py_new[(fb_py_new.Match>=20) &
(fb_py_new['Position'] == 'DF') &
(fb_py_new['Age'] < 35) &
(fb_py_new['Pass'] >= 1000) &
(fb_py_new['PassComp%'] >= 70) &
(fb_py_new['CrossCompleted'] >= 10) &
(fb_py_new.Position.str.contains('DF'))].sort_values(['CrossCompleted','PassComp%'], ascending = False).head(15).iloc[:, [0,2,3,4,5,11,10,12,19,20,21]])
DF_9_10
Out[44]:
| Player | Position | Team | Age | Match | PassCompleted | Pass | PassComp% | Cross | CrossCompleted | CrossComp% | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 493 | Kieran Trippier | DF | Newcastle Utd | 32 | 22 | 1133 | 1587 | 71.4 | 226 | 20 | 8.85 |
| 13 | Trent Alexander-Arnold | DF | Liverpool | 24 | 20 | 1039 | 1423 | 73.1 | 137 | 17 | 12.41 |
| 410 | Antonee Robinson | DF | Fulham | 25 | 20 | 763 | 1041 | 73.3 | 70 | 13 | 18.57 |
In [45]:
DF_9_10_is = DF_9_10['Player'].head(2)
print('ตำแหน่งกองหลังปีกซ้าย ขวา ' )
DF_9_10_is
ตำแหน่งกองหลังปีกซ้าย ขวา
Out[45]:
493 Kieran Trippier 13 Trent Alexander-Arnold Name: Player, dtype: object
ทีมที่สุดในปีนี้จากการเลือกโดยใช้ข้อมูลที่มี¶
In [46]:
import plotly.express as px
data = dict(
categories = ['Attackers', 'Midfielders', 'Defenders',
'Haaland', 'Kane', 'Salah',
'Ødegaard', 'De Bruyne', 'Rodri',
'Trippier', 'Van Dijk', 'Kurt Zouma', 'Trent'],
parent = [ '', '', '', 'Attackers', 'Attackers', 'Attackers', 'Midfielders', 'Midfielders', 'Midfielders', 'Defenders', 'Defenders', 'Defenders', 'Defenders'],
value = [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40])
fig = px.sunburst(data,
names = 'categories',
parents = 'parent',
values = 'value')
fig.update_layout(title='Team My Data',
title_font_size=20)
fig.show()
In [ ]:
In [48]:
# export data to a CSV file
# data.to_csv('mydata.csv', index=False)
# export data to an Excel file
fb_py_new.to_excel('fb_py_new.xlsx', index=False)
In [ ]: